var alertMessage = {
	slideDown : function() {
		$("#alertMessage > div ").slideDown("normal", function() {
			setTimeout("alertMessage.slideUp()", 4000);
		});
	},
	slideUp : function() {
		$("#alertMessage > div ").slideUp("normal", function() {
			$(this).html("");
		});
	},

	// TODO:Will be deprecated!
	show : function(msgType, msg) {
		$("#alertMsg").removeClass("alert-success alert-error");
		if (msgType == 'success')
			$("#alertMsg").addClass("alert-success");
		if (msgType == 'error')
			$("#alertMsg").addClass("alert-error");
		$("#alertMsg").find("p").html(msg);
		$("#alertMsg").show();
		setTimeout("alertMessage.hide()", 3000);
	},
	// TODO:Will be deprecated!
	hide : function() {
		$("#alertMsg").hide();
	}
};

var ajaxTimeOut;
var alertAjaxMessage = {
	slideDown : function(messageType, message) {
		if ($("#alertAjaxMessage").length > 0)
			$("#alertAjaxMessage").remove();
		if(ajaxTimeOut!=undefined)
			clearTimeout(ajaxTimeOut);
		if($("#alertMessage").length>0)
	    {
			$("#alertMessage > div ").slideUp("normal", function() {
				$(this).html("");
			});
	    }
		var messageStyle = "";
		var messageTitle = "";
		switch (messageType) {
		case "success":
			messageStyle = "hide alert-success";
			messageTitle = "Success!";
			break;
		case "error":
			messageStyle = "alert-error";
			messageTitle = "Error!";
			break;
		case "warning":
			messageTitle = "Warning!";
			break;
		case "info":
			messageStyle = "hide alert-info";
			messageTitle = "Information!";
			break;
		default:
			messageStyle = "alert-info";
			messageTitle = "Information!";
		}

		var alertMessageHtml = "<div class='message' id='alertAjaxMessage'>";
		alertMessageHtml = alertMessageHtml + "<div class='alert "
				+ messageStyle + "' >";
		alertMessageHtml = alertMessageHtml + "<h3>" + messageTitle + "</h3>";
		alertMessageHtml = alertMessageHtml + "<p>" + message + "</p>";
		alertMessageHtml = alertMessageHtml + "</div>";
		alertMessageHtml = alertMessageHtml + "</div>";
		$("#main .widget:first").before(alertMessageHtml);
		if(messageType=="success"||messageType=="info")
		{
		  $("#alertAjaxMessage>div").slideDown("normal", function() {
		    	ajaxTimeOut=setTimeout("alertAjaxMessage.slideUp()", 4000);
		  });
	    }
	},
	slideUp : function() {
		$("#alertAjaxMessage>div").slideUp("normal", function() {
			$("#alertAjaxMessage").remove();
		});
	}
}

